#include <opencv2/opencv.hpp>
#include <iostream>

using namespace cv;
using namespace std;

int main() {
    Mat image = imread("../../../src/cre/scripts/temp/image.jpg"); // 读取图像
    if (image.empty()) {
        cout << "Cannot read image file" << endl;
        return -1;
    }

    Mat gray, binary;
    cvtColor(image, gray, COLOR_BGR2GRAY); // 将图像转换为灰度图像
    threshold(gray, binary, 128, 255, THRESH_BINARY); // 进行二值化操作

    namedWindow("Original Image", WINDOW_NORMAL);
    namedWindow("Binary Image", WINDOW_NORMAL);

    imshow("Original Image", image);
    imshow("Binary Image", binary);

    waitKey(0);
    return 0;
}